#define Motor_Count 2 // 修改为定义两个直流电机
int motor_pin[4] = {5, 6, 9, 10}; // 定义直流电机引脚

void Motor_pin_init() //初始化直流电机引脚
{
  for(int i=0;i<Motor_Count * 2;i++)
  {
    pinMode(motor_pin[i],OUTPUT);
  }
  // 初始化电机速度
  analogWrite(motor_pin[2], 100); // 设置PWM值，范围0-255
}

void Motor_Go(int mode) //定义小车状态。mode表示小车模式，speeds表示小车速度
{
  switch(mode)
  {
    case Forward: {
      digitalWrite(motor_pin[0], HIGH);
      digitalWrite(motor_pin[1],LOW);
      delay(1000);
//      analogWrite(motor_pin[2],speeds);
//      analogWrite(motor_pin[3],0);
    }break;
    case Back: {
      digitalWrite(motor_pin[0], HIGH);
      digitalWrite(motor_pin[1],LOW);
      delay(1000);
//      analogWrite(motor_pin[2],0);
//      analogWrite(motor_pin[3],speeds);
    }break;
    case Left: {
      digitalWrite(motor_pin[0], HIGH);
      digitalWrite(motor_pin[1],LOW);
      delay(1000);
//      analogWrite(motor_pin[2],0);
//      analogWrite(motor_pin[3],speeds);
    }break;
    case Right: {
      digitalWrite(motor_pin[0], HIGH);
      digitalWrite(motor_pin[1],LOW);
      delay(1000);
//      analogWrite(motor_pin[2],speeds);
//      analogWrite(motor_pin[3],0);
    }break;
    case Stop: {
      digitalWrite(motor_pin[0], LOW);
      digitalWrite(motor_pin[1],LOW);
      delay(1000);
//      analogWrite(motor_pin[2],speeds);
//      analogWrite(motor_pin[3],speeds);
    }break;
    default: break;   
  }
}